%{
#include <stdlib.h>
#include <stdio.h>
#include "attack.tab.h"
%}

%option yylineno
%x comment string defzero

%%

   /* Handle comments */
"/*"         BEGIN(comment);
<comment>[^*\n]*        /* eat anything that's not a '*' */
<comment>"*"+[^*/\n]*   /* eat up '*'s not followed by '/'s */
<comment>\n             /*++yylineno;*/
<comment>"*"+"/"        BEGIN(INITIAL);

#if[ ]*0  			BEGIN(defzero);
<defzero>#endif 	BEGIN(INITIAL);
<defzero>[^#] 		/* */

#define { return DEFINE; }

AT_[A-Z_0-9]+     {yylval.s = strdup(yytext+3); return TYPE;}
AD_[A-Z_0-9]+     {yylval.s = strdup(yytext+3); return DAMAGE;}
MM_[A-Z_0-9]+     {yylval.s = strdup(yytext+3); return MONMON;}
-?[0-9]+       {yylval.i = atoi(yytext); return INT;}
\(-?[0-9]+\)   {yylval.i = atoi(yytext+1); return INT;}
0x[0-9]+	   {yylval.i = (int)strtol(yytext+2, NULL, 16); return INT;}
[A-Z_]+ 
[ \t]+  /* eat */
\n      /* eat */
^[^#]       /* eat */
#ifndef[^\n]+  { return IFNDEF; }
#endif[^\n]*   { return ENDIF; }
<<EOF>> {return THE_END;}
%%

int yywrap() {
 return 1;
}
